var gulp = require('gulp'),  
less = require('gulp-less'),
autoprefixer = require('gulp-autoprefixer'),
cleancss = require('gulp-clean-css'),
uglify = require('gulp-uglify'),
rename = require('gulp-rename'),
concat = require('gulp-concat'),
sourcemap = require('gulp-sourcemaps'),
browsersync = require('browser-sync');


gulp.task('less', function(){
    gulp.src('src/less/*.less') 
        .pipe( less() ) 
        .pipe(autoprefixer({
            browsers:['last 2 versions']
        }))
        .pipe( gulp.dest('src/css') )
        .pipe(sourcemap.init()) 
        .pipe(cleancss())
        .pipe(rename({
            suffix:'.min'
        }))
        .pipe(sourcemap.write('./'))
        .pipe( gulp.dest('src/css') )
        .pipe(browsersync.stream());
})


gulp.task('serve',['less'], function() {  
    browsersync.init({  
        server: "./src"  
    });  
    gulp.watch("src/less/*.less", ['less']);  
    gulp.watch("./src/**/*.*").on('change', browsersync.reload);  
});   
gulp.task('default', ['serve','less']);